﻿/*
ParallelPlatform Project - A web platform to distribute and share knowledge
Online Editor - An online tool to create and play animations
Copyright (C) 2011 Daniel Guerrero Martínez & Sergio Rodríguez Lumley

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package Classes{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	public class ToolBoxButton extends MovieClip {
		//private var selectFunction:Function;
		private var type:uint = 0;
		
		public static const SELECT:uint = 0;
		public static const INSERT:uint = 1;
		public static const REMOVE:uint = 2;
		public static const TEXT:uint = 3;
		public static const ARROW:uint = 4;
		public static const BLUR:uint = 5;
		public static const CREATE:uint = 6;
		
		/**
		Sets the type of the button
		@param t Type of the button
		*/
		public function setType(t:uint){
			type = t;
		}
		
		/**
		Gets the type of the button
		*/
		public function getType(){
			return type;
		}
		
		/**
		Sets the function to call after being selected
		@param f Function to call
		*/
		/*public function setSelectFunction(f:Function){
			selectFunction = f;
		}*/
		
		/**
		Sets the button as the one being selected
		*/
		public function selectEvent(evt:MouseEvent){
			select();
		}
		public function select(){
			gotoAndStop(3);
			//selectFunction(type);
		}
		
		/**
		Stops the button from being selected
		*/
		public function unselectEvent(evt:MouseEvent){
			unselect();
		}
		public function unselect(){
			gotoAndStop(1);
		}
		
		/**
		Draws the button as it is being hovered
		*/
		public function hoverEvent(evt:MouseEvent){
			hover();
		}
		public function hover(){
			if(currentFrame != 3) // If not selected
				gotoAndStop(2);
		}
		
		/**
		Stops the button from being hovered
		*/
		public function unhoverEvent(evt:MouseEvent){
			unhover();
		}
		public function unhover(){
			if(currentFrame != 3) // If not selected
				gotoAndStop(1);
		}
	}
}